﻿<!--#Include File="../Inc/Const.Asp"-->
<!--#Include File="Inc/Class_Field.Asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>字段管理</title>
<script language="JavaScript" type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
<script language="JavaScript" type="text/javascript" src="js/common.js"></script>
<script language="javascript">
function checkForm()
{
	var title = $("#oFieldTitle").val();
	if(title=='')
	{
		alert('请输入字段名称');return false;
	}
}
</script>
<link href="Images/Style.Css" rel="stylesheet" type="text/css" />
</head>
<body>
<%

Dim U
Set U = New Cls_FormField

Dim Rs,Ns,Sql,Style,i
Dim ID,FID
    ID = Request("ID")
	FID = Request("FID")
Select Case Request("Act")
Case "Guide"
	If Len(ID) = 0 Then
		Call U.Initialize()
		Call Main_Guide(0)
	Else
		U.vID = ID
		Call U.SetValue()
		Call Main_Guide(1)
	End If
Case "UpDate"
	If U.GetValue() Then
		If Len(ID) = 0 Then
			If Not U.Create() Then
				Alert U.LastError,"Admin_Field.Asp?FID="&FID
			Else
				Alert "","Admin_Field.Asp?FID="&FID
			End If
		Else
			U.vID = ID
			If Not U.Modify() Then
				Alert U.LastError,"Admin_Field.Asp?FID="&FID
			Else
				Alert "","Admin_Field.Asp?FID="&FID
			End If
		End If
	Else
		Alert U.LastError,"Admin_Field.Asp?FID="&FID
	End If
Case "Delete"
	If Len(ID) > 0 Then
		U.vID = ID
		If Not U.Delete() Then
			Alert U.LastError,"Admin_Field.Asp?FID="&FID
		Else
			Alert "","Admin_Field.Asp?FID="&FID
		End If
	Else
		Call Main()
	End If
Case Else
	Call Main()
End Select

Set U = Nothing
If IsObject(Conn) Then Conn.Close : Set Conn = Nothing

Sub Main()

Set Rs = New DataList
Rs.Field = "[ID],[FieldTitle],[FieldName],[FieldType],[DefaultValue],[IsMustInput]"
Rs.Table = "[{pre}FormField]"
Rs.Where = " [FormID]=" & FID
Rs.List()
%>
<table width=100% border=0 cellpadding=3 cellspacing=1 class=css_table bgcolor='#E1E1E1'>
	<tr class=css_menu>
		<td colspan=8><table width=100% border=0 cellpadding=4 cellspacing=0 class=css_main_table>
					<tr>
						<td class=css_main><a href=Admin_Field.Asp?FID=<%=FID%>>字段列表</a> <a href=Admin_Field.Asp?Act=Guide&FID=<%=FID%>>新增字段</a></td>
						<td class=css_search>&nbsp;</td>
					</tr>
			</table></td>
	</tr>
		<tr>
			<td width="50" class='css_top'>编号</td>
			<td width="154" class='css_top'>字段名称</td>
			<td width="154" class='css_top'>字段标识</td>
			<td width="154" class='css_top'>字段类型</td>
			<td width="511" class='css_top'>默认值</td>
			<td width="66" class='css_top'>必填</td>
			<td width="154" class='css_top'>管理</td>
		</tr>
		<%
		If Rs.Eof Then
		%>
		<tr align="center" class=css_norecord>
			<td colspan=8>没有任何记录！</td>
		</tr>
		<%
		Else
		For i = 0 To UBound(Rs.Data,2)
		%>
		<tr>
			<td width="50" class='css_list'><%=Rs.Data(0,i)%></td>
			<td class='css_list'><div align="left"> &nbsp;<a href="Admin_Field.Asp?Act=Guide&ID=<%=Rs.Data(0,i)%>"><%=Rs.Data(1,i)%></a></div></td>
		  <td width="154" class='css_list'><%=Rs.Data(2,i)%></td>
			<td width="154" class='css_list'><%=Rs.Data(3,i)%></td>
			<td width="511" class='css_list'><%=Rs.Data(4,i)%></td>
		  <td width="66" class='css_top'><%If Rs.Data(5,i)=0 Then response.Write "否" else response.Write "是"%></td>
			<td width="154" class='css_list'>
			<input name=modify type=button onclick="location.href='Admin_Field.Asp?Act=Guide&ID=<%=Rs.Data(0,i)%>&FID=<%=FID%>';" value=修改>
		  <input name=delete type=button onclick="if(confirm('您确定要删除这条记录吗?')){location.href='Admin_Field.Asp?Act=Delete&ID=<%=Rs.Data(0,i)%>';}" value=删除></td>
		</tr>
		<%
		Next
		End If
		%>
</table>
<%
Set Rs = Nothing
End Sub

Sub Main_Guide(T)
%>
<table width=100% border=0 cellpadding=3 cellspacing=1 class=css_table bgcolor='#E1E1E1'>
	<tr class=css_menu>
		<td colspan=3><table width=100% border=0 cellpadding=4 cellspacing=0 class=css_main_table>
				<tr>
					<td class=css_main><a href=Admin_Field.Asp?FID=<%=FID%>>模型字段管理</a></td>
				</tr>
			</table></td>
	</tr>
	<form name='frm' id="frm" method='post' action='Admin_Field.Asp?Act=UpDate&ID=<%=ID%>&FID=<%=Request("FID")%>'>
		
		<tr>
			<td width="138" class=css_col11_content><div align="right"> 字段名称： </div></td>
			<td width="1157" colspan="2" class=css_col21><input name="oFieldTitle" type="text" class="css_input" id="oFieldTitle" value="<%=U.vFieldTitle%>" size="40" /></td>
		</tr>
		<tr>
  <td class=css_col11_content><div align="right"> 字段标识： </div></td>
  <%If Len(U.vFieldName)=0 Then U.vFieldName="fd"&Int(timer)%>
	      <td colspan="2" class=css_col21><input name="oFieldName" type="text" class="css_input" id="oFieldName" value="<%=U.vFieldName%>" size="40" /><font color="#FF0000">前台调用标签：{field:ext字段标识}</font></td>
	      </tr>
<tr>
		  <td class=css_col11_content><div align="right"> 字段类型： </div></td>
	  <td colspan="2" class=css_col21><select name="oFieldType" id="oFieldType">
            <option value="SingleLine" <%if U.vFieldType="SingleLine" then response.Write "selected=selected"%>>单行文本框</option>
            <option value="MultiLine" <%if U.vFieldType="MultiLine" then response.Write "selected=selected"%>>多行文本框</option>
            <option value="RadioButtonList" <%if U.vFieldType="RadioButtonList" then response.Write "selected=selected"%>>单项选择框（单项按钮）</option>
            <option value="CheckBoxList" <%if U.vFieldType="CheckBoxList" then response.Write "selected=selected"%>>多项选择框（复选按钮）</option>
            <option value="DropDownList" <%if U.vFieldType="DropDownList" then response.Write "selected=selected"%>>下拉选择框</option>
            <option value="DateTime" <%if U.vFieldType="DateTime" then response.Write "selected=selected"%>>日期/时间</option>
			<option value="Files" <%if U.vFieldType="Files" then response.Write "selected=selected"%>>文件上传</option>
          </select>
</td>
	  </tr>
		<tr>
		  <td class=css_col11_content><div align="right"> 默 认 值： </div></td>
		  <td colspan="2" class=css_col21><textarea type="text" name="oDefaultValue" id="oDefaultValue" rows=10 cols=30><%=U.vDefaultValue%></textarea>(多选选择的默认值每行一个)</td>
	  </tr>
		<tr>
			<td class=css_col11_content><div align="right"> 必 填 项： </div></td>
			<td colspan="2" class=css_col21>
			<input type="radio" name="oIsMustInput" id="oIsMustInput" value="0"  <%If U.vIsMustInput=0 Then response.Write "checked=checked"%>  />否
			<input type="radio" name="oIsMustInput" id="oIsMustInput" value="1" <%If U.vIsMustInput=1 Then response.Write "checked=checked"%> />是
			</td>
		</tr>
		<tr class=css_page_list>
			<td colspan=3><input name='Submit' type='submit' value='保存' onclick="return checkForm()">			</td>
		</tr>
	</form>
</table>
</div>
<%
End Sub
%>
</body>
</html>
